#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    const int dx[4] = { -1,0,0,1 };
    const int dy[4] = { 0,1,-1,0 };
    int dfs(vector<vector<int>>& grid, int x, int y) {
        grid[x][y] = 2;
        int area = 1;
        for (int i = 0; i < 4; i++)
        {
            int mx = x + dx[i], my = y + dy[i];
            if (grid[mx][my] == 1)
            {
                grid[mx][my] = 2;
                area += dfs(grid, mx, my);
            }
        }
        return area;
    }
    int maxAreaOfIsland(vector<vector<int>>& grid) {
        int area = 0;
        for (int i = 0; i < grid.size(); i++)
        {
            for (int j = 0; j < grid[i].size(); j++)
            {
                if (grid[i][j] == 1)
                {
                    area = max(area, dfs(grid, i, j));
                }
            }
        }
        return area;
    }
};
int main()
{
    vector<vector<int>> grid  = { {0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0},{0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0},{0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0},{0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0},{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0},{0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0},{0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0} };
    Solution s;
    cout<<s.maxAreaOfIsland(grid);
    return 0;
}